<?php if (!defined('SERVER_ROOT')) {exit('No direct script access allowed');}
//header
$this->template->title = 'BCKH';
$this->template->display('dsp_header.php');
$v_MA_DON_VI_filter        = $arr_filter['cbx_MA_DON_VI_filter'];
$v_MA_TO_CHUYEN_MON_filter = $arr_filter['cbx_MA_TO_CHUYEN_MON_filter'];
$v_MA_CAN_BO_filter = $arr_filter['cbx_MA_CAN_BO_filter'];
$v_TYPE_filter = $arr_filter['hdn_TYPE_filter'];
?>
 <form name="frmMain" id="frmMain" action="" method="POST">
    <?php
    echo $this->hidden('controller',$this->get_controller_url());
    echo $this->hidden('hdn_item_id','0');
    echo $this->hidden('hdn_macanbo','0');
    echo $this->hidden('hdn_item_id_list','');

    echo $this->hidden('hdn_dsp_single_method','dsp_single_bckh');
    echo $this->hidden('hdn_dsp_all_method','dsp_all_bckh');
    echo $this->hidden('hdn_update_method','update_bckh');
    echo $this->hidden('hdn_delete_method','delete_bckh');
    echo $this->hidden('hdn_TYPE_filter', $v_TYPE_filter);
    $v_row = 0;
    ?>
   <div id="div_filter">
        <label>Đơn vị</label>
        <select id="cbx_MA_DON_VI_filter"
                name="cbx_MA_DON_VI_filter"
                onchange="cbx_MA_DON_VI_filter_onchange(this)"
                >
                  <?php while ($arr = $arr_all_donvi_filter->FetchRow()): ?>
                  <?php
                   $MA=$arr['MA_DON_VI'];
                   $TEN=$arr['TEN_DON_VI'];
                  ?>
                   <?php if($v_MA_DON_VI_filter == $MA):?>
                     <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                  <?php else:?>
                     <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                  <?php endif ?>
                <?php endwhile; ?>
        </select>
        <label>Tổ/bộ môn</label>
        <select id="cbx_MA_TO_CHUYEN_MON_filter"
                name="cbx_MA_TO_CHUYEN_MON_filter"
                onchange="cbx_MA_TO_CHUYEN_MON_filter_onchange(this);"
                >
                  <?php while ($arr = $arr_all_tochuyenmon_filter->FetchRow()): ?>
                  <?php
                   $MA=$arr['MA_TO_CHUYEN_MON'];
                   $TEN=$arr['TEN_TO_CHUYEN_MON'];
                  ?>
                   <?php if($v_MA_TO_CHUYEN_MON_filter == $MA):?>
                     <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                  <?php else:?>
                     <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                  <?php endif ?>
                <?php endwhile; ?>
        </select>
        <label>Cán bộ</label>
        <select id="cbx_MA_CAN_BO_filter"
                name="cbx_MA_CAN_BO_filter"
                onchange="cbx_MA_CAN_BO_filter_onchange(this);">
                  <?php while ($arr = $arr_all_canbo_filter->FetchRow()): ?>
                  <?php
                   $MA=$arr['MA_CAN_BO'];
                   $TEN=$arr['TEN_CAN_BO'];
                  ?>
                   <?php if($v_MA_CAN_BO_filter == $MA):?>
                     <option value="<?php echo $MA; ?>" selected="selected"><?php echo $TEN; ?></option>
                      <?php $v_TEN_CAN_BO_filter=$TEN; ?>
                  <?php else:?>
                     <option value="<?php echo $MA; ?>" ><?php echo $TEN; ?></option>
                  <?php endif ?>
                <?php endwhile; ?>
        </select>
       <?php if ($v_MA_DON_VI_filter !='' && $v_MA_TO_CHUYEN_MON_filter !=0 && $v_MA_CAN_BO_filter !=0): ?>
        <div><input style="margin-top: 10px" class = 'button' type="button" name="btn_add_nckh" value="Thêm BCKH" onclick="row_bckh_onclick_pop_win('0','<?php echo $v_MA_CAN_BO_filter; ?>','<?php echo $v_TEN_CAN_BO_filter; ?>')"/></div>
       <?php endif?>
    </div>
    <table  width="100%" class="adminlist" cellspacing="0" border="1">
        <colgroup>
            <col width="20%" />
            <col width="15%" />
            <col width="20%" />
            <col width="20%" />
            <col width="4%" />
            <col width="8%" />
            <col width="13%" />
        </colgroup>
        <tr>
            <th>Tên BCKH</th>
            <th>CB thực hiện</th>
            <th>Học kỳ</th>
            <th>Tên loại BCKH</th>
            <th>SGC</th>
            <th>Duyệt</th>
            <th>Thao tác</th>
        </tr>
        <?php while ($arr = $arr_all_bckh->FetchRow()): ?>
            <?php
            $id=1;
             $TEN_BCKH=$arr['TEN_BCKH'];
             $MA_CAN_BO=$arr['MA_CAN_BO'];
             $TEN_CAN_BO=$arr['TEN_CAN_BO'];
             $TEN_HOC_KY=$arr['TEN_HOC_KY'];
             $TEN_LOAI_BCKH=$arr['TEN_LOAI_BCKH'];
             $SO_GIO_CHUAN_QUI_DOI=$arr['SO_GIO_CHUAN_QUI_DOI'].'h';
             $DA_DUYET=$arr['DA_DUYET'];
             $v_class = 'row' . ($v_row % 2);
             $v_row++;
            ?>
            <tr class="<?php echo $v_class;?>">
                <td style="vertical-align:middle"><?php echo $TEN_BCKH;?></td>
                <td style="vertical-align:middle"><?php echo $TEN_CAN_BO;?></td>
                <td style="vertical-align:middle"><?php echo $TEN_HOC_KY;?></td>
                <td style="vertical-align:middle"><?php echo $TEN_LOAI_BCKH;?></td>
                <td style="text-align:center;vertical-align:middle"><?php echo $SO_GIO_CHUAN_QUI_DOI;?></td>
                <td style="text-align:center;vertical-align:middle"><?php echo $DA_DUYET;?></td>
                <td style="text-align:center;vertical-align:middle">
                    <a href="javascript:void(0)" onclick="row_bckh_onclick_pop_win('<?php echo $TEN_BCKH;?>','<?php echo $MA_CAN_BO;?>','<?php echo $TEN_CAN_BO;?>')">Sửa</a> |
                    <a href="javascript:void(0)" onclick="quick_delete_bckh('<?php echo $TEN_BCKH;?>','<?php echo $MA_CAN_BO;?>','<?php echo $TEN_CAN_BO;?>')">Xoá</a> |
                    <a href="javascript:void(0)" onclick="quick_duyet_bckh('<?php echo $TEN_BCKH;?>','<?php echo $MA_CAN_BO;?>','<?php echo $TEN_CAN_BO;?>')">Duyệt</a>
                </td>
            </tr>
        <?php endwhile; ?>
        <?php echo $this->add_empty_rows($v_row +1, _CONST_DEFAULT_ROWS_PER_PAGE, 7); ?>
    </table>

</form>
<script>
    function cbx_MA_DON_VI_filter_onchange(e){
       var f = document.frmMain;
       f.hdn_TYPE_filter.value =  'MA_DON_VI';
       f.submit();
    }
    function cbx_MA_TO_CHUYEN_MON_filter_onchange(e){
       var f = document.frmMain;
       f.hdn_TYPE_filter.value =  'MA_TO_CHUYEN_MON';
       f.submit();
    }
    function cbx_MA_CAN_BO_filter_onchange(e){
       var f = document.frmMain;
       f.hdn_TYPE_filter.value =  'MA_CAN_BO';
       f.submit();
    }
    function row_bckh_onclick_pop_win(tenbckh,macanbo,tencanbo){
        var url = '<?php echo $this->get_controller_url();?>dsp_single_bckh/'  + tenbckh
            url += '/?&tenbckh=' + tenbckh + '&hdn_item_id=' + tenbckh;
            url +=  '&macanbo=' + macanbo + '&tencanbo=' + tencanbo + '&pop_win=1';
        showPopWin(url ,600,350, null);
    }

    function quick_delete_bckh(tenbckh,macanbo,tencanbo)
    {
        var f = document.frmMain;
        if (confirm('Bạn chắc chắn xoá đối tượng đã chọn?')){
            f.hdn_item_id.value =  tenbckh;
            f.hdn_macanbo.value =  macanbo;
            m = $("#controller").val() + 'delete_bckh'
            $("#frmMain").attr("action", m);
            f.submit();
        }
    }
    function quick_duyet_bckh(tenbckh,macanbo,tencanbo){
        var f = document.frmMain;
        if (confirm('Bạn chắc chắn muốn duyệt BCKH?')){
            f.hdn_item_id.value =  tenbckh;
            f.hdn_macanbo.value =  macanbo;
            m = $("#controller").val() + 'duyet_bckh'
            $("#frmMain").attr("action", m);
            f.submit();
        }
    }
</script>
<?php $this->template->display('dsp_footer.php');